/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPnlWizardAnalysisSteps.java
 *
 * Created on 19/03/2011, 18:25:31
 */
package systole.view.wizard.analysis;

import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;
import systole.utils.ImageUtils;
import systole.view.wizard.PageController;
import systole.view.wizard.StepsController;

/**
 *
 * @author jmj
 */
public class JPnlWizardAnalysisSteps extends javax.swing.JPanel implements StepsController {

    private Font plainFont;
    private Font boldFont;
    private Icon ok;
    private Icon pendent;
    private Color startColor = new Color(192, 192, 192);
    private Color endColor = new Color(82, 82, 82);

    /** Creates new form JPnlWizardAnalysisSteps */
    public JPnlWizardAnalysisSteps() {
        initComponents();
        this.plainFont = this.jLblClinicalInfo.getFont();
        this.boldFont = new Font(this.jLblClinicalInfo.getFont().getName(), Font.BOLD, this.jLblClinicalInfo.getFont().getSize());      
        this.pendent = ImageUtils.buildIcon("resources/icons/ballRed/ball16.png");
        this.ok =ImageUtils.buildIcon("resources/icons/ok/ok16.png");
        this.jLblClinicalInfo.setForeground(Color.white);
        this.jLblPatient.setForeground(Color.white);
        this.jLblPulses.setForeground(Color.white);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLblPulses = new javax.swing.JLabel();
        jLblPatient = new javax.swing.JLabel();
        jLblClinicalInfo = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JPnlWizardAnalysisSteps.class);
        jLblPulses.setIcon(resourceMap.getIcon("jLblPulses.icon")); // NOI18N
        jLblPulses.setText(resourceMap.getString("jLblPulses.text")); // NOI18N
        jLblPulses.setName("jLblPulses"); // NOI18N

        jLblPatient.setIcon(resourceMap.getIcon("jLblPatient.icon")); // NOI18N
        jLblPatient.setText(resourceMap.getString("jLblPatient.text")); // NOI18N
        jLblPatient.setName("jLblPatient"); // NOI18N

        jLblClinicalInfo.setIcon(resourceMap.getIcon("jLblClinicalInfo.icon")); // NOI18N
        jLblClinicalInfo.setText(resourceMap.getString("jLblClinicalInfo.text")); // NOI18N
        jLblClinicalInfo.setName("jLblClinicalInfo"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLblPulses)
                    .addComponent(jLblPatient)
                    .addComponent(jLblClinicalInfo))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLblPulses)
                .addGap(18, 18, 18)
                .addComponent(jLblPatient)
                .addGap(18, 18, 18)
                .addComponent(jLblClinicalInfo)
                .addContainerGap(130, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLblClinicalInfo;
    private javax.swing.JLabel jLblPatient;
    private javax.swing.JLabel jLblPulses;
    // End of variables declaration//GEN-END:variables

    public void markAsDone(PageController page) {
        if (FirstPageController.KEY.equals(page.getKey())) {
            this.jLblPulses.setIcon(this.ok);
            this.revalidate();
            return;
        }

        if (SecondPageController.KEY.equals(page.getKey())) {
            this.jLblPatient.setIcon(this.ok);
            this.revalidate();
            return;
        }

        if (ThirdPageController.KEY.equals(page.getKey())) {
            this.jLblClinicalInfo.setIcon(this.ok);
            this.revalidate();
            return;
        }
    }

    public void markAsUndo(PageController page) {
        if (FirstPageController.KEY.equals(page.getKey())) {
            this.jLblPulses.setIcon(this.pendent);
            this.revalidate();
            return;
        }

        if (SecondPageController.KEY.equals(page.getKey())) {
            this.jLblPatient.setIcon(this.pendent);
            this.revalidate();
            return;
        }

        if (ThirdPageController.KEY.equals(page.getKey())) {
            this.jLblClinicalInfo.setIcon(this.pendent);
            this.revalidate();
            return;
        }
    }

    public void setAsCurrentPage(PageController page) {

        if (FirstPageController.KEY.equals(page.getKey())) {
            this.jLblPulses.setFont(this.boldFont);
        } else {
            this.jLblPulses.setFont(this.plainFont);
        }

        if (SecondPageController.KEY.equals(page.getKey())) {
            this.jLblPatient.setFont(this.boldFont);
        } else {
            this.jLblPatient.setFont(this.plainFont);
        }

        if (ThirdPageController.KEY.equals(page.getKey())) {
            this.jLblClinicalInfo.setFont(this.boldFont);
        } else {
            this.jLblClinicalInfo.setFont(this.plainFont);
        }
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g;

        GradientPaint gp1 = new GradientPaint(0, 0, startColor, 0, this.getHeight() - 1, endColor, false);

        g2d.setPaint(gp1);
        g2d.fillRect(this.getX(), this.getY(), this.getWidth(), this.getHeight());

    }
}
